var t = require;
var e = module;
var o = exports;
var n =
        (this && this.__extends) ||
        (function () {
            var t = function (e, o) {
                return (t =
                    Object.setPrototypeOf ||
                    ({__proto__: []} instanceof Array &&
                        function (t, e) {
                            t.__proto__ = e;
                        }) ||
                    function (t, e) {
                        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                    })(e, o);
            };
            return function (e, o) {
                function n() {
                    this.constructor = e;
                }
                t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
            };
        })(),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var r,
                a = arguments.length,
                i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
            return a > 3 && i && Object.defineProperty(e, o, i), i;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var a = t("Platforms"),
    i = cc._decorator,
    s = i.ccclass,
    c =
        (i.property,
        (function (t) {
            function e() {
                return (null !== t && t.apply(this, arguments)) || this;
            }
            var o;
            return (
                n(e, t),
                (o = e),
                (e.prototype.init = function (t) {
                    var e = this;
                    (o.instance = this),
                        (this.black = this.node.getChildByName("black")),
                        (this.txt = this.node.getChildByName("txt").getComponent(cc.Label)),
                        (this.loading = t),
                        this.black.on(cc.Node.EventType.TOUCH_END, function () {
                            o.showDetails
                                ? ((o.showDetails = !1), (e.black.height = 32))
                                : ((o.showDetails = !0), (e.black.height = 560)),
                                o.updateInfos();
                        });
                }),
                (e.start = function (t, e) {
                    this.instance &&
                        ((this.instance.node.active = !1),
                        this.names.indexOf(t) > -1
                            ? console.error("重复 start：" + t)
                            : (e > 0 || (e = new Date().getTime()),
                              this.names.push(t),
                              this.nodes.push({startMs: e, endMs: 0}),
                              (this.currName = t),
                              this.updateInfos()));
                }),
                (e.end = function (t) {
                    if (this.instance) {
                        var e = this.names.indexOf(t);
                        if (e > -1) {
                            var o = this.nodes[e];
                            o.endMs > 0
                                ? console.error("已 end：" + t)
                                : ((o.endMs = new Date().getTime()),
                                  this.updateInfos(),
                                  this.instance.loading.progress(t, 0.1));
                        } else console.error("木有 " + t);
                    }
                }),
                (e.done = function () {
                    (this.currName = ""),
                        (this.instance.loading = null),
                        (this.doneTime = new Date().getTime()),
                        (this.总耗时 = Math.round((this.doneTime - window.startTime) / 10) / 100),
                        this.updateInfos(),
                        this.showDetails || (this.instance.node.active = !1),
                        a.default.platformCtrl.加载完毕();
                }),
                (e.clear = function () {
                    this.instance && (this.instance.node.destroy(), (this.instance = null));
                }),
                (e.updateInfos = function () {
                    this.showDetails
                        ? (this.instance.txt.string = this.getDetails())
                        : (this.instance.txt.string = this.currName);
                }),
                (e.getDetails = function () {
                    for (var t = "", e = -1, o = 0, n = this.nodes; o < n.length; o++) {
                        var r = n[o];
                        e++,
                            (t += this.names[e] + " " + (r.endMs > 0 ? r.endMs - r.startMs + "毫秒" : "进行中") + "\n");
                    }
                    return this.doneTime > 0 && (t += "总耗时" + this.总耗时 + "秒\n"), t;
                }),
                (e.names = []),
                (e.nodes = []),
                (e = o = r([s], e))
            );
        })(cc.Component));
o.default = c;
